package com.nuoniu.sibanyun.mapper.erp.in;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.bo.UsedGradeRuleBo;
import com.nuoniu.sibanyun.entity.erp.in.InInventoryLocation;
import com.nuoniu.sibanyun.entity.erp.in.InWarehouse;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 货位 Mapper 接口
 * </p>
 *
 * @author baiqiang
 * @since 2020-09-22
 */
public interface InInventoryLocationMapper extends BaseMapper<InInventoryLocation> {

    @Update("update scb_storagebin set warehouse_name = #{whName} where warehouse_id = #{id}")
    void updateWarehouse(InWarehouse inWarehouse);

    @Select("select * from scb_storagebin where warehouse_id in (${inWarehouseId})")
    List<InInventoryLocation> getByWarehouse(String inWarehouseId);

    @Select("select id from scb_storagebin where warehouse_id = #{warehouseId}")
    List<Integer> getByWarehouseId(Integer warehouseId);

    @Select("select * from scb_storagebin where code=#{code} and company_id=#{companyId} ")
    InInventoryLocation getByCode(InInventoryLocation location);

    @Select("select * from scb_storagebin where name=#{name} and company_id=#{companyId}")
    InInventoryLocation getByName(InInventoryLocation location);

    /**
     * 批量同步 货位名称 和 货位编码
     * @param location
     */
    void batchUpdateFromInInventoryLocation(InInventoryLocation location);

}
